home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 127_01 / rap.h < prev    next >
Text File  |  1985-03-09  |  15KB  |  520 lines

  1. /*********************************************************************\
  2. ** .---------------------------------------------------------------. **
  3. ** |                                                               | **
  4. ** |                                                               | **
  5. ** |         Copyright (c) 1981, 1982, 1983 by Eric Martz.         | **
  6. ** |                                                               | **
  7. ** |                                                               | **
  8. ** |       Permission is hereby granted to use this source         | **
  9. ** |       code only for non-profit purposes. Publication of       | **
  10. ** |       all or any part of this source code, as well as         | **
  11. ** |       use for business purposes is forbidden without          | **
  12. ** |       written permission of the author and copyright          | **
  13. ** |       holder:                                                 | **
  14. ** |                                                               | **
  15. ** |                          Eric Martz                           | **
  16. ** |                         POWER  TOOLS                          | **
  17. ** |                    48 Hunter's Hill Circle                    | **
  18. ** |                      Amherst MA 01002 USA                     | **
  19. ** |                                                               | **
  20. ** |                                                               | **
  21. ** `---------------------------------------------------------------' **
  22. \*********************************************************************/
  23.  
  24. /*--------------------------------------------------------------------------
  25.  
  26. HEADER FILE FOR "ROFF AND PRINT" = RAP by Eric Martz.
  27. The RAP program is built on ROFF.C by Kathy Bacon, which was obtained
  28. from the BDSC Users Group. ROFF.C, in turn, is an adaptation of
  29. Kernighan and Plauger's ROFF in RATFOR in their book Software Tools.
  30.  
  31. The first functional RAP was created in August-October 1981.
  32. Debugging, additions and augmentations have continued through the
  33. present (August, 1983).
  34.  
  35. --------------------------------------------------------------------------
  36. KNOWN BUGS:
  37.  
  38.     1. Tabs not working if line has substitutions.
  39.     
  40.     2. Justification (spread()) doesnt work.
  41.  
  42. --------------------------------------------------------------------------
  43. Obsolete Bug (autospacing code has been defeated)
  44.  
  45.          No double space after period ending sentence when sentence
  46.         ends at end of input line. Difficult to correct since getspaces()
  47.         cant look ahead to see if next word is capitalized. Left as is
  48.         in accord with preference to fail to double space rather than
  49.         put in inappropriate double spaces, e.g. a line ending in Dr.
  50.         Somebody as does the previous line.
  51.  
  52. --------------------------------------------------------------------------
  53.  
  54. FILE LOCATIONS OF RAP FUNCTIONS:
  55.  
  56. P=RAP.C
  57. 1=RAP1.C etc.
  58. R=RAPREAD.C
  59.  
  60. FUNCTION    FILE    CALLS
  61. -----------------------------------------------------------
  62. main            P    dioinit, init_defaults, anotherline,
  63.                 command, text, dioflush
  64.  
  65. anotherline    3    saveextra, rapgets, ss, expand_controls
  66.  
  67. baud            R    rapgets, de-comment
  68.  
  69. biggets        4
  70.  
  71. brk            3
  72.  
  73. center        1
  74.  
  75. checkbig        4
  76.  
  77. command        1    comtyp, get_val, brk, set, checkbig, gettl, read_command
  78.                 find_portion, getpairs, restore_mode, space
  79.  
  80. comtyp        1
  81.  
  82. de_comment    4
  83.  
  84. expand_controls3
  85.  
  86. expantab        4
  87.  
  88. fillbuf        3
  89.  
  90. fillulbuf        3    getspaces, fillbuf
  91.  
  92. find_portion    R    rapgets
  93.  
  94. getpairs        4    ssgets, de_comment, ioport, baud
  95.  
  96. getspaces        3
  97.  
  98. gettl        2    skip_blanks, substitute
  99.  
  100. getval        1
  101.  
  102. getwrd        3    
  103.  
  104. indent        2
  105.  
  106. init_defaults    P
  107.  
  108. init_ss        4    rapgets, de_comment, checkbig, command, getpairs
  109.  
  110. init_text        2
  111.  
  112. ioport        R    rapgets, de_comment
  113.  
  114. leadbl        2
  115.  
  116. open_read        R
  117.  
  118. phead        2    skip, puttl
  119.  
  120. pfoot        2    skip, puttl
  121.  
  122. put            2    phead, indent, putline, skip, pfoot
  123.  
  124. putline        3    ss, indent
  125.  
  126. puttl        2    ss, restore_mode
  127.  
  128. putwrd        3    brk, fillbuf
  129.  
  130. rapgets        4    biggets
  131.  
  132. read_command    R    open_read
  133.  
  134. restore_mode    2
  135.  
  136. saveextra        3
  137.  
  138. screen_status    R
  139.  
  140. set            1
  141.  
  142. skip            2
  143.  
  144. skip_blanks    1
  145.  
  146. space        2    brk, skip, pfoot
  147.  
  148. spread        1    trunc_bl
  149.  
  150. ss            4    delchars, substitute, checkbig
  151.  
  152. ssgets        4    rapgets
  153.  
  154. text            2    init_text, space, leadbl, expantab, fillulbuf,
  155.                 put, restore_mode, center, getwrd, getspaces,
  156.                 putwrd, checkbig
  157.  
  158. trunc_bl        1
  159.  
  160. --------------------------------------------------------------------------*/
  161.  
  162. #include <bdscio.h>
  163. #include "bdscio+.h"
  164.  
  165. /*--------------------------------------------------------------------------
  166. Version history:
  167.  
  168. 1.0->1.1:
  169.  
  170. Change of input file does not automatically begin a new page.
  171. Initialization string comes from {init{ in SS#.
  172. Bug in }RF} fixed.
  173. \\ // -> {{ }}
  174.  
  175. 1.1->1.2:
  176.  
  177. Don't double space after a period unless preceding word length > 3.
  178. Replace {#{ with auto-incrementing arabic number.
  179. Direct "no ss0 file" error message to STDERR.
  180.  
  181. 1.2->2.0:
  182. Implemented ".re filename portion" command.
  183. Implemented {ux{/{dx{ macro expansion for super/sub-scripts.
  184. Implemented .ss 1/0 command.
  185. Made PORT_OUT the dioinit() default.
  186.  
  187. 2.0->2.0a:
  188. Implemented built-in substitutions.
  189. Changed SS0-9 to SSx...
  190. Added .d1, .d2, .ou.
  191. Implemented commands in SS capability, i/o port, baud in SS.
  192.  
  193. 2.0a->2.0b = 2.00
  194. Rearranged argument parsing so '>/...' overrides .ou in SS.
  195. Added '>' to zero _Outflag.
  196. Fixed head/foot flushing and centering for proportional fonts.
  197. Implemented '.bo' command.
  198. Implemented VIEW capability.
  199.  
  200. 2.00 -> 2.10
  201. Changed SSFILE to FILE.SS to work with Microshell. (DEFAULT.SS)
  202. Used #ifdef DEBUG to remove all debugging code to reduce size.
  203. Linked with L2 to reduce size. Externals 8c00.
  204. #defined FILENAME as 16 to accept drive specification.
  205. Fixed badname() to accept drive specification.
  206. Implemented Deinit, Interrupted (with ^C dioflush()).
  207. Added backspace to cancel space from console in view mode.
  208.  
  209. 2.10 -> 2.11
  210. Changed NAKED_NEWLINE from ^N to ^] ("group separator", ASCII 1Dh, 29d)
  211. Redirection mark '/' changed to ')'
  212.  
  213. 2.11 -> 2.12
  214. {#{ is incremented only when {#+{; only one per input line.
  215. A repeated original ss string causes the new replacement to replace the
  216.     former replacement.
  217.  
  218. 2.12 -> 2.13
  219.     .br now starts a ".pi" paragraph (Tival = Pival).
  220.  
  221. 2.13 -> 2.14
  222.     .fn range 0-5 expanded to 0-16
  223.  
  224. 2.14 -> 2.15
  225. added }"console prompt} feature
  226. added }wait} function
  227. added .cf continuous forms
  228. added .bl blanking character
  229. arranged to have lines beginning with an invalid command passed into text()
  230.  
  231. 2.15 -> 2.16
  232. deleted NAKED_NEWLINE feature
  233. added "compress control" feature with exception for ^J (->naked)
  234.     to allow ^Z
  235.  
  236. 2.16 -> 2.17
  237. made non-continuous forms not wait at page bottoms with -p# flag
  238.  
  239. 2.17 -> 2.18
  240. fixed underlining when }u+} not defined and filling in putwrd()
  241.     to account for post-substitutions and backspaces
  242.  
  243. 2.18 -> 2.19
  244. Added .lf command for printers which generate auto-lf on cr; also, when
  245.     .lf 1, a literal cr (as in a segmented header) generates a Rev_lf.
  246.  
  247. 2.19 -> 2.20
  248. Removed coded licensee ident; commented out portion code with .re.
  249. Made getspaces() use same spacing as input text.
  250. Added {_...{, {!...{.
  251. Rebuilt underlining and boldfacing code, all processing at output.
  252.     Added shift and restore for each.
  253. Bug which failed to break at blank line containing spaces fixed.
  254. Added 10 new dot commands: .ar, .bd, .ed, .i@, .ig, .ix, .ne,
  255.     .p#, .pd, .tc.
  256.  
  257. 2.20 -> 2.21
  258. Defeated blank-squeezing in ss()
  259. Fixed centering to ignore leading/trailing white
  260.  
  261. --------------------------------------------------------------------------*/
  262. /*--------------------------------------------------------------------------
  263.  
  264. GENERAL PURPOSE CONSTANTS
  265.  
  266. --------------------------------------------------------------------------*/
  267.  
  268. #define    STDERR        4
  269. /* send error messages to console while in DIO */
  270.  
  271. #define    CTRL_C        '\3'
  272. #define    BIGBUF        512
  273. #define    HUGE            135    /* generally large number */
  274. #define    FILENAME        16    /* big enough for cp/m name A:12345678.123 */
  275. #define    COMMAND        '.'    /* all commands starts with this */
  276.  
  277. #define    LIST_OUT    2
  278. #define    UNKNOWN        -1    /* returned i